package com.iwunu.gateway.util;

import java.util.ArrayList;
import java.util.List;

import com.iwunu.gateway.entity.CmdIssued;
import com.iwunu.gateway.entity.ImageMongo;

/**
 * @author kinfeng
 * @date 2020/7/5 10:47 AM
 * @description
 */
public class PitNumUtil {
    public static final Integer MAX_PIT_NUM=100;
    public static final Integer IMAGE_MAX_PIT_NUM=20;
    
    public static Integer getImagePitNum(List<ImageMongo> imageMongos){
    	List<Integer> removeList  = new ArrayList<>();
        if(imageMongos==null || imageMongos.size()==0){
            return 0;
        }
        for(ImageMongo imageMongo:imageMongos) {
        	removeList.add(imageMongo.getPitNum());
        }
        List<Integer> list = pitNumList();
        list.removeAll(removeList);
        return list.get(0);
    }
    public static List<Integer> getCmdPitNum(List<CmdIssued> cmdIssueds,Integer length){
    	List<Integer> removeList  = new ArrayList<>();
    	List<Integer> newList =  new ArrayList<Integer>();
        List<Integer> list = pitNumList();
        if(cmdIssueds==null || cmdIssueds.size()==0){
        	newList = list.subList(0, length);
        	 return newList;
        }
        for(CmdIssued cmdIssued:cmdIssueds) {
            removeList.add(cmdIssued.getPitNum());
         }	
        list.removeAll(removeList);
        newList = list.subList(0, length);
        return newList;
    }
   
    private static List<Integer> pitNumList(){
        List<Integer> pitList = new ArrayList<>();
        for(int i=1;i<=MAX_PIT_NUM;i++){
            pitList.add(i);
        }
        return pitList;
    }
    private static List<Integer> imagePitNumList(){
        List<Integer> pitList = new ArrayList<>();
        for(int i=1;i<=IMAGE_MAX_PIT_NUM;i++){
            pitList.add(i);
        }
        return pitList;
    }
    public static void main(String[] args) {
        List<Integer> list1 = new ArrayList<>();
        list1.add(1);

        List<Integer> list2 = new ArrayList<>();
        list2.add(2);

        List<Integer> list3 = new ArrayList<>();
        list3.add(3);

    }
}
